/**
 * Relative time
 * ---------------------------------------------------------------------------------------------------------------------
 */
// import dayjs from "dayjs"
// import 'dayjs/locale/zh-cn'
// import relativeTime from 'dayjs/plugin/relativeTime'
// dayjs.locale('zh-ch')
// dayjs.extend(relativeTime)

// export function rtime(time) {
//     return dayjs().to(dayjs(time))
// }

/**
 * K number
 * ---------------------------------------------------------------------------------------------------------------------
 */
export function knumber(number) {
    const num = parseInt(number)
    if (num < 1000) return number
    number = number + ''
    return number.substring(0, number.length - 3) + 'k'
}

export function brokerageNum(number) {
    return Number(number).toFixed(2)
}

export function ellipsis(value, length = 10) {
    if (!value) return ''
    if (value.length > length) {
        return value.slice(0, length) + '...'
    }
    return value
}


export function bankCardNum(num) {
		var number = num
    var reg = /^(\d{4})\d+(\d{4})$/;
    number = number.replace(reg, "$1 **** **** $2");
		
    return number
}

export function timeFormatSeconds (time) {
    var d = time ? new Date(time) : new Date();
    var year = d.getFullYear();
    var month = d.getMonth() + 1;
    var day = d.getDate();
    var hours = d.getHours();
    var min = d.getMinutes();
    var seconds = d.getSeconds();

    if (month < 10) month = '0' + month;
    if (day < 10) day = '0' + day;
    if (hours < 0) hours = '0' + hours;
    if (min < 10) min = '0' + min;
    if (seconds < 10) seconds = '0' + seconds;

    return (year + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + seconds);
}
 
